package spring_learn.a01;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

@Service
public class UserService {


    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    public void registerUser(){
        System.out.println("service user register");
        //通过ApplicationEventPublisher发布用户注册事件
        applicationEventPublisher.publishEvent(new UserRegisteredEvent(this));
    }
}
